package org.example.rmsmsapi.service;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.example.rmsmsapi.Utils.DateUtils;
import org.example.rmsmsapi.config.DS;
import org.example.rmsmsapi.dao.testMapper;
import org.example.rmsmsapi.model.*;
import org.example.rmsmsapi.model.Req.*;
import org.example.rmsmsapi.model.Res.*;
import org.example.rmsmsapi.sdao.smapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class rmsmsapiservice {
    @Resource
    private testMapper mapper;

    @Resource
    private smapper apper;

    @DS("datasource2")
    public List<testUser> getUser(){
        return mapper.getUser();
    }
    /***获取清算明细数据**/
    @DS("datasource1")
    public List<qsdetailRes> getQsdetail(qsdataReq req){
        List<qsdetailRes> res = new ArrayList<>();
        res=apper.GetqsinfoDetail(req);
        return res;
    }
    /*获取银行卡信息**/
   @DS("datasource1")
   public   List<bankInfo>  GetBankInfo(bankInfo b){
        List<bankInfo> list=new ArrayList<>();
        list=apper.GetbankInfo(b.getIdcardNo());
        if(list!=null&&list.size()>0){
     return list;
        }
        else {
List<rmspeson> mlist=new ArrayList<>();
            rmspeson r=new rmspeson();
            r.setIdcardNo(b.getIdcardNo());
mlist=apper.GetRMsperinfo(r);
if(mlist!=null&&mlist.size()>0){
   for (int i = 0; i < mlist.size(); i++) {
       bankInfo b1=new bankInfo();
       b1.setName(mlist.get(i).getName());
       b1.setIdcardNo(mlist.get(i).getIdcardNo());
       list.add(b1);
   }
   return list;
}
else {
    return null;
}
        }

   }
   //编辑银行卡信息
    @DS("datasource1")
   public  List<bankInfo> EditerBankInfo(bankInfo b){
    List<bankInfo> list=new ArrayList<>();
    list=apper.GetbankInfo(b.getIdcardNo());
    if(list!=null&&list.size()>0){
        apper.UpdateBankInfo(b);
        list=apper.GetbankInfo(b.getIdcardNo());
        return list;
    }
    else {
        apper.saveBankInfo(b);
        list=apper.GetbankInfo(b.getIdcardNo());
        return list;
    }
    }
    /**通过身份证号获取患者医保信息**/
    @DS("datasource2")
    public List<ybbxInfo>GetybbxInfo(String sfzh){
        List<ybbxInfo> list = new ArrayList<>();
        list=mapper.GetybinfobyId(sfzh);
        if(list.size()>0){
            for(int i=0;i<list.size();i++){
                list.get(i).setBxlb(mapper.Getxzlb(list.get(i).getJzh()));
                list.get(i).setYllb(mapper.GetYllb(list.get(i).getJzh()));
                MRCBean b=new MRCBean();
                b=mapper.GetMrcFirst(list.get(i).getJzh(),"Y");
                List<MRCBean> m=new ArrayList<>();
                m=mapper.GetMrcEnd(list.get(i).getJzh());
                String cyqtzd="";
                if (m.size()>0){
                    for (int k = 0; k < m.size(); k++) {
                        cyqtzd=cyqtzd+m.get(k).getMRCID_Desc()+";";
                    }
                }
                list.get(i).setCyqtzd(cyqtzd);
                if(b!=null){
                    list.get(i).setCyzyzdmc(b.getMRCID_Desc());
                }
                else {
                    b=mapper.GetMrcFirst(list.get(i).getJzh(),"N");
                    list.get(i).setCyzyzdmc(b.getMRCID_Desc());
                }
            }
            return list;
        }
        return null;
    }
/***组装退役军人信息*/
@DS("datasource1")
    public  List<ybbxInfo> assembleYbinfo( List<ybbxInfo> list){
        if (list==null||list.size()==0){
            return null;
        }
    if (list.size()>0){
 for (int i = 0; i < list.size(); i++) {
     RsmTpBean b=new RsmTpBean();
     b=apper.getRmsTpBeanByCard(list.get(i).getSfzh());
     list.get(i).setBxbl(b.getBxbl());
     list.get(i).setTpcode(b.getTpcode());
     list.get(i).setTpname(b.getTpname());
     list.get(i).setCbdmc(apper.GetYbCbd(list.get(i).getCbdbh()));
 }
return list;
        }
        else {return  null;}

    }

    /**登录**/
@DS("datasource1")
    public String  Login(String userCode,String p){
    suser s=new suser();
 s=apper.GetUserByUserCodeAndPass(userCode,p);
 if(s!=null){
 apper.uPuser(s.getUserId(), DateUtils. Getdnowdatexx());
     suser s1=new suser();
     s1=apper.GetUserByUserCodeAndPass(userCode,p);
     ArrayList<String> r=new ArrayList<>();
     r=apper.GetPermes(s1.getRoleid());
     uRoles u=new uRoles();
     u.setRoles(r);
     u.setUserCode(s1.getUserCode());
     u.setCreateTime(s1.getCreateTime());
     u.setStop(s1.getStop());
     u.setHosId(s1.getHosId());
     u.setLoginTime(s1.getLoginTime());
     u.setUserName(s1.getUserName());
     u.setUserId(s1.getUserId());
     u.setUserType(s1.getUserType());
     //u.setToken(s1.getToken());
     u.setAvatar(s1.getAvatar());
     u.setIntroduction(s1.getIntroduction());
     userRes res=new userRes();
        res.setResultCode("0");
        res.setResultMsg("success");
        res.setData(u);
//     userInfo info=new userInfo();
//     info.setUser(u);
//     ResInfo resInfo=new ResInfo();
//     resInfo.setResultCode("0");
//     resInfo.setResultMsg("success");resInfo.setData(JSON.toJSONString(u));
     return JSON.toJSONString(res);
 }
    ResInfo res=new ResInfo();
  res.setResultCode("0");
  res.setResultMsg("用户名和密码不符合，请检查！");
 return JSON.toJSONString(res);
 }
 /**获取退役军人信息**/
 @DS("datasurce1")
    public List<rmspeson> Getrmspeson(rmspeson r){
     List<rmspeson> list=new ArrayList<>();
     list=apper.GetRMsperinfo(r);
     return list;
 }
 /**验证是否是tyjr*/
 public boolean validateRmsperson(String sfzh){
     rmspeson res=new rmspeson();
     res.setStop("0");
     res.setIdcardNo(sfzh);
     List<rmspeson> list=new ArrayList<>();
     list=Getrmspeson(res);
     if (list.size()>0){
return true;
     }
     else {
         return false;
     }
 }
 @DS("datasource1")
    public void Updatermspeson(rmspeson r){
     apper.upRsms(r);
 }
 /**新增tyjr信息*/
 @DS("datasource1")
 public void  Insertmspeson(rmspeson r){
     List<rmspeson> list=new ArrayList<>();
     list=apper.GetRMsperinfo(r);
     if(list.size()==0||list==null){
         apper.insertRsms(r);
     }
   else return;
 }

 /**进行二次报账**/
 @DS("datasource1")
 public  List<insudoReq>  insudoInfo(insudoReq req){
     List<insudoReq> list=new ArrayList<>();
     List<insudoReq>mlist=new ArrayList<>();
     //保留两位小数格式化
     DecimalFormat df = new DecimalFormat("#.00");
     insudoReq r=req;
     r.setSfzf("0");
     mlist=apper.GetinsuInfo(r);
     if(mlist==null||mlist.size()==0){
         String tpcode=req.getTpcode();
         String sfjsff=req.getSfjsff();
         String ecbxfy="";
         Double bxbl;
         Double nrbxje;
         Double ecbxhzfje;
           nrbxje=Double.parseDouble(req.getZje())-Double.parseDouble(req.getJjzfze())
                   -Double.parseDouble(req.getZfje())-Double.parseDouble(req.getCxjzffy());
         bxbl=Double.parseDouble(apper.getbxbl(sfjsff,tpcode));
         ecbxfy= df.format(nrbxje*bxbl);
         ecbxhzfje=Double.parseDouble(req.getZje())-Double.parseDouble(req.getJjzfze())
                 -Double.parseDouble(ecbxfy);
//         if(tpcode.equals("1")){
//             if(sfjsff.equals("1")){
//                 ecbxfy=req.getNrecbzje();
//             }
//             else {
//                 ecbxfy= df.format(Double.parseDouble(req.getNrecbzje())*0.8);
//             }
//         }
//         else if(tpcode.equals("2")){
//             ecbxfy=req.getNrecbzje();
//         }
//         else if(tpcode.equals("3")){
//             ecbxfy= df.format(Double.parseDouble(req.getNrecbzje())*0.8);
//         }
//         else {
//             ecbxfy="0";
//         }
        req.setNrecbzje(df.format(nrbxje));
         req.setEcbxje(ecbxfy);
        req.setEcbxhzfje(df.format(ecbxhzfje));
        // System.out.print(JSON.toJSONString(req));
         apper.insudop(req);
         list=apper.GetinsuInfo(req);
         return list;
     }
     else {return null;}


 }
 /***获取退役军人历史报账信息*/
 public List<insudoReq> GetinsuSec(insudoReq req){
     List<insudoReq> list=new ArrayList<>();
     list=apper.GetinsuInfo(req);
     return list;
 }
 /**通过类型获取具体的对账单的明细信息*/
 public List<insudoReq>Getdztpinsudetail(dzddetailreq r){
     return apper.GetrecldetailBytptime(r);
 }
 /***获取院内对账信息*/
 @DS("datasource1")
 public List<dzdinfo>Getdzinfo(dzdinfo d){
     return  apper.Getdzlist(d);
 }

 @DS("datasource1")
 @Transactional(readOnly = true)
 public String canclehosdzd(dzdinfo d){
     System.out.print(JSON.toJSONString(d));
     dzdinfo dz=new dzdinfo();
     dz.setZfrybh(null);
     dz.setZfryxm(null);
     dz.setZfbz(null);
     List<dzdinfo> list=new ArrayList<>();
      list=apper.Getdzlist(dz);
      if (list==null||list.size()==0){
         return "未查询到可以作废的对账单";
      }
      else {
          apper.Canclehosdzd(d);
          apper.uprmshosdzd(d);
          return "对账单号："+d.getDzdh()+"作废成功!";
      }
 }
 @DS("datasource1")
// 获取未清算信息用于生成清算数据
 public qsdRes Gethosqsinfo(liquiReq r){
     qsjeinfo info= new qsjeinfo();
     info=apper.Getqsje(r);
     if(info==null){
         return null;
     }
     else {
         qsdRes res=new qsdRes();
         usandhosinfo uho=new usandhosinfo();
         System.out.print("请求参数:"+JSON.toJSONString(r));
         //通过用户号获取人员和医院信息
         uho=apper.Getryandhosinfo(r.getUserCode());
         res.setEndtime(r.getEndtime());
         res.setStarttime(r.getStarttime());
         res.setHosCode(uho.getHosCode());
         res.setHosName(uho.getHosName());
         res.setQsje(info.getQsje());
         res.setQsbz("0");
         res.setQsrs(info.getBs());
         res.setHoslevel(uho.getHoslevel());
         res.setQssqrybm(uho.getUserCode());
         res.setQssqryxm(uho.getUserName());
         res.setQssqsj(r.getQssqsj());
         res.setHosId(uho.getHosId());

         return res;
     }

 }

 /**获取清算信息**/
 @DS("datasource1")
 public List<qsdRes> Getqsinfo(qsdRes r){
     List<qsdRes> list=new ArrayList<>();
     list=apper.Getqsinfo(r);
     if(list==null||list.size()==0){
         return null;
     }
     else {
         return list;
     }
 }
/**获取清算数据用于清算审核，作废，查询等**/
    public List<qsdRes> Getqsinfo1(qsdRes r){
        List<qsdRes> list=new ArrayList<>();
        list=apper.Getqsinfo1(r);
        if(list==null||list.size()==0){
            return null;
        }
        else {
            return list;
        }
    }
 @DS("datasource1")
 /***获取医院键值对，用于前端查询选择医院*/
 public List<hosmapInfo> getHosMap(){
     return  apper.GethosMap();
 }
 //保存清算表
    @DS("datasource1")
 public qsdRes saveqsinfo(qsdRes r){
     List<qsdRes> list=new ArrayList<>();
     list=apper.Getqsinfo(r);
     if (list==null||list.size()==0){
     apper.saveqsb(r);
         list=apper.Getqsinfo(r);
         if(list==null||list.size()==0){
             return null;
         }
        // System.out.print("ttttttt"+JSON.toJSONString(list));
         r.setQsid(list.get(0).getQsid());
     //反写明细表
     apper.Upqsdetail(r);

     return list.get(0);
     }
     else {
         return list.get(0);
     }
 }
/***更新清算信息，用于作废和审核**/
 public qsdRes upQsinfo(qsdRes r){
     System.out.print("数据"+JSON.toJSONString(r));
 /***更新清算表**/
      apper.upqsbinfo(r);
      /**反写更新明细表**/
     apper.Upqsdetail1(r);
     List<qsdRes> list=new ArrayList<>();

     list=apper.Getqsinfo(r);

     return list.get(0);

 }
 /***通过时间获取对账单信息**/
 @DS("datasource1")
 public List<dzdinfo>GetdzinfoBytime(dzdinfo d){
    return apper.Getdzlistbytime(d);
 }
/***获取退役军人人员类型信息*/
 @DS("datasource1")
    public List<rmsType>GetrmsType(){
     return apper.GetRmsTpInfo();
 }
 /**获取医院信息**/
 @DS("datasource1")
 public List<hosinfo> Gethosinfo(hosinfo h){
     List<hosinfo> list=new ArrayList<>();
     list=apper.Gethosinfos(h);
     return list;
 }
 /***获取用户匹配对象**/
 @DS("datasource1")
 public userMatchModel GetuserMatchModel(){
List<roleMap> roleMapList=new ArrayList<>();
roleMapList=apper.GetRoleMap();
List<hosMap> hosMapList=new ArrayList<>();
hosMapList=apper.GetHosMap();
userMatchModel userMatchModel=new userMatchModel();
userMatchModel.setRoleMapList(roleMapList);
userMatchModel.setHosMapList(hosMapList);
return userMatchModel;
 }

    /**获取角色信息**/
    @DS("datasource1")
    public List<roleModel> Getroleinfo(roleModel h){
        List<roleModel> list=new ArrayList<>();
        list=apper.Getroleinfos(h);
        return list;
    }
    /**获取人员类型信息**/
    @DS("datasource1")
    public List<personTypeModel> GetpersonTypenfo(personTypeModel h){
        List<personTypeModel> list=new ArrayList<>();
        list=apper.GetPersonTypeinfo(h);
        return list;
    }


    /**获取用户信息**/
    @DS("datasource1")
    public List<userinfoRes> Getuserinfo(userinfoModel h){
        List<userinfoRes> list=new ArrayList<>();
        list=apper.GetUserinfos(h);
        return list;
    }

 /***更新人员类型信息**/
    @DS("datasource1")
    public List<personTypeModel> UpperonTypeinfo(personTypeModel h){
     apper.UpdatePersonType(h);
        List<personTypeModel> list=new ArrayList<>();
        list=apper.GetPersonTypeinfo(h);
        return list;
    }

    /***更新医院信息**/
    @DS("datasource1")
    public List<roleModel> Uproleinfo(roleModel h){
        apper.upRoleInfo(h);
        List<roleModel> list=new ArrayList<>();
        list=apper.Getroleinfos(h);
        return list;
    }

    /***更新用户信息**/
    @DS("datasource1")
    public List<userinfoRes> Upuserinfo(userinfoModel h){
        apper.upUserinfo(h);
        List<userinfoRes> list=new ArrayList<>();
        list=apper.GetUserinfos(h);
        return list;
    }

    /***更新医院信息**/
    @DS("datasource1")
    public List<hosinfo> Uphosinfo(hosinfo h){
        apper.updateHosinfo(h);
        List<hosinfo> list=new ArrayList<>();
        list=apper.Gethosinfos(h);
        return list;
    }
    /***保存医院信息**/
    @DS("datasource1")
    public List<roleModel> saveroleinfo(roleModel h){
        apper.addRoleInfo(h);
        List<roleModel> list=new ArrayList<>();
        list=apper.Getroleinfos(h);
        return list;
    }

    /***保存角色信息**/
    @DS("datasource1")
    public List<hosinfo> saveHosinfo(hosinfo h){
        apper.insertHosinfo(h);
        List<hosinfo> list=new ArrayList<>();
        list=apper.Gethosinfos(h);
        return list;
    }

    /***保存用户类型信息**/
    @DS("datasource1")
    public List<personTypeModel> savepersonTypeinfo(personTypeModel h){
        List<personTypeModel> list=new ArrayList<>();
        list=apper.GetPersonTypeinfo(h);
        if(list==null||list.size()==0){
            apper.AddPersonType(h);
            list=apper.GetPersonTypeinfo(h);
            return list;
        }
        return list;
    }
    /***保存用户信息**/
    @DS("datasource1")
    public List<userinfoRes> saveUserinfo(userinfoModel h){
        apper.addUserinfo(h);
        List<userinfoRes> list=new ArrayList<>();
        list=apper.GetUserinfos(h);
        return list;
    }
@DS("datasource1")
//获取已经对账的对账单和还未对账的对账单用于对账查询
public dzinfoRes GetdzdBYque(dzdinfo r){
    List<dzdinfo>list=new ArrayList<>();
    dzinfoRes res=new dzinfoRes();
    list=apper.Getdzlist(r);
    List<renclitype> rlist=new ArrayList<>();
    usandhosinfo uho=new usandhosinfo();
    //通过用户号获取人员和医院信息
    uho=apper.Getryandhosinfo(r.getUserCode());
    String zje;
    String startTime="";
    String endTime="";
    if(r.getStartTime()!=null){
    startTime=r.getStartTime().toString();}
    if(r.getEndTime()!=null){
    endTime=r.getEndTime().toString();}

    zje=apper.Getdzzje(startTime,endTime,r.getUserCode());
    if(list==null||list.size()==0){
        startTime="2025-01-01";
        //获取未对账信息按照类型返回
        rlist= apper.GetAllRenclitypeProvider(r);
        if(rlist==null||rlist.size()==0){
            return null;
        }
        else {
            res.setDzdh(r.getDzdh());
            res.setDzsj(endTime);
            res.setStartTime(startTime);
            res.setUserCode(r.getUserCode());
            res.setUserName(uho.getUserName());
            res.setDzje(zje);
            res.setHosName(uho.getHosName());
            res.setHosId(uho.getHosId());
            res.setUserName(uho.getUserName());
            res.setZfbz("0");
            res.setEndTime(endTime);
            res.setRenclitypeList(rlist);
            return res;
        }
    }
    else {
           // startTime=  DateUtils.converttimetoYYMMDDHH00(st);}
        //获取未对账信息按照类型返回
        rlist= apper.GetAllRenclitypeProvider(r);
        if(rlist==null||rlist.size()==0){
            return null;
        }
        else {
            res.setDzdh(r.getDzdh());
            res.setDzsj(endTime);
            res.setStartTime(startTime);
            res.setUserCode(r.getUserCode());
            res.setUserName(uho.getUserName());
            res.setDzje(list.get(0).getDzje());
            res.setHosId(uho.getHosId());
            res.setUserName(uho.getUserName());
            res.setZfbz(r.getZfbz());
            res.setHosName(uho.getHosName());
            res.setEndTime(endTime);
            res.setRenclitypeList(rlist);
            return res;
        }


}}
    /***获取未对账信息List***/
    public List<norencque> GetnoRencinfo(norencque r){
     return  apper.GetnoRenc(r);
    }

 /***返回数据用于生成对账单**/
 @DS("datasource1")
 public dzinfoRes Getreconlist(dzdinfo r){
     List<dzdinfo>list=new ArrayList<>();
     dzinfoRes res=new dzinfoRes();
     list=apper.Getdzlist(r);
     List<renclitype> rlist=new ArrayList<>();
     usandhosinfo uho=new usandhosinfo();
     //通过用户号获取人员和医院信息
     uho=apper.Getryandhosinfo(r.getUserCode());
     String startTime="";String endTime=DateUtils.converttimetoYYMMDDHH00(DateUtils.Getdnowdatexx());
     String zje;
     zje=apper.Getdzzje(startTime,endTime,r.getUserCode());
     if(list==null||list.size()==0){
         startTime="2025-01-01";
         //获取未对账信息按照类型返回
      rlist= apper.GetAllRenclitype(startTime,endTime,r.getUserCode(),"0");
      if(rlist==null||rlist.size()==0){
          return null;
      }
      else {
          res.setDzsj(endTime);
          res.setStartTime(startTime);
          res.setUserCode(r.getUserCode());
          res.setUserName(uho.getUserName());
          res.setDzje(zje);
          res.setHosName(uho.getHosName());
          res.setHosId(uho.getHosId());
          res.setUserName(uho.getUserName());
          res.setZfbz("0");
          res.setEndTime(endTime);
          res.setRenclitypeList(rlist);
          return res;
      }
     }
     else {
         String st="";
         st=apper.GetDZcreatetime(r.getUserCode(),"0");
         if(st==null){
             return null;
         }
         else {
    startTime=  DateUtils.converttimetoYYMMDDHH00(st);}
         //获取未对账信息按照类型返回
         rlist= apper.GetAllRenclitype(startTime,endTime,r.getUserCode(),"0");
         if(rlist==null||rlist.size()==0){
             return null;
         }
         else {
             res.setDzsj(endTime);
             res.setStartTime(startTime);
             res.setUserCode(r.getUserCode());
             res.setUserName(uho.getUserName());
             res.setDzje(zje);
             res.setHosId(uho.getHosId());
             res.setUserName(uho.getUserName());
             res.setZfbz("0");
             res.setHosName(uho.getHosName());
             res.setEndTime(endTime);
             res.setRenclitypeList(rlist);
             return res;
         }
     }

 }

 @DS("datasource1")
// 生成对账单，保存数据库
 @Transactional(readOnly = true)
 public dzinfoRes genaretdzd(dzdinfo r){
     List<dzdinfo>list=new ArrayList<>();
     dzinfoRes res=new dzinfoRes();
     if(r.getDzdh()==null){
     r.setZfbz("0");}
     List<renclitype> rlist=new ArrayList<>();
      list=apper.Getdzlist(r);
      if(list==null||list.size()==0){
      apper.insertRencli(r);
          list=apper.Getdzlist(r);
          r.setDzdh(list.get(0).getDzdh());
      apper.upRencliRmesdeta(r);
      rlist=apper.GetAllRenclitype(r.getStartTime(),r.getEndTime(),r.getUserCode(),"1");
          res.setDzdh(list.get(0).getDzdh());
          res.setZfbz(list.get(0).getZfbz());
          res.setStartTime(list.get(0).getStartTime());
          res.setEndTime(list.get(0).getEndTime());
          res.setUserCode(list.get(0).getUserCode());
          res.setUserName(list.get(0).getUserName());
          res.setDzje(list.get(0).getDzje());
          res.setHosName(list.get(0).getHosName());
          res.setHosId(list.get(0).getHosId());
          res.setDzsj(list.get(0).getDzsj());
          res.setRenclitypeList(rlist);
          if(list.get(0).getShbz()!=null){
              res.setShbz(list.get(0).getShbz());
          }
          if(list.get(0).getShrybh()!=null){
              res.setShrybh(list.get(0).getShrybh());
          }
          if(list.get(0).getShryxm()!=null){
              res.setShryxm(list.get(0).getShryxm());
          }
          return res;
      }
      else {
          rlist=apper.GetAllRenclitype(r.getStartTime(),r.getEndTime(),r.getUserCode(),"1");
          res.setDzdh(list.get(0).getDzdh());
          res.setZfbz(list.get(0).getZfbz());
          res.setStartTime(list.get(0).getStartTime());
          res.setEndTime(list.get(0).getEndTime());
          res.setUserCode(list.get(0).getUserCode());
          res.setUserName(list.get(0).getUserName());
          res.setDzje(list.get(0).getDzje());
          res.setHosName(list.get(0).getHosName());
          res.setHosId(list.get(0).getHosId());
          res.setDzsj(list.get(0).getDzsj());
          res.setRenclitypeList(rlist);
          if(list.get(0).getShbz()!=null){
              res.setShbz(list.get(0).getShbz());
          }
          if(list.get(0).getShrybh()!=null){
              res.setShrybh(list.get(0).getShrybh());
          }
          if(list.get(0).getShryxm()!=null){
              res.setShryxm(list.get(0).getShryxm());
          }
         return res;
      }
 }
 /**获取退役军人结算明细信息**/
 public List<insudoReq>GetInsucostDetail(insuinfobydateReq req){
    return  apper.GetinsoinfoDetail(req);
 }
/***更新报销信息，主要用于作废**/
 public List<insudoReq>UpInsucostDetail(insudoReq  req){
     apper.upjsinfo(req);
    return apper.GetinsuInfo(req);
 }
/***获取角色对应权限信息**/
@DS("datasource1")
public  rcpRes Getrcpinfo(){
    roleModel h=new roleModel();
    List<roleModel> list=new ArrayList<>();
    //获取角色信息
    list=apper.Getroleinfos(h);
    List<roleCordetail> rlist=new ArrayList<>();
    for(int i=0;i<list.size();i++){
        List<RcpModel>rcpModels= new ArrayList<>();
        rcpModels=apper.GetrcpList(list.get(i).getRoleid());
        roleCordetail r=new roleCordetail();
        r.setRoleid(list.get(i).getRoleid());
        r.setRolename(list.get(i).getRolename());
        r.setDydata(rcpModels);
        rlist.add(r);
     }
    List<perInfo>plist=new ArrayList<>();
    //获取权限信息
    plist= apper.GetPerinfos();

    rcpRes res=new rcpRes();
    res.setRoles(rlist);
    res.setPers(plist);

    return res;

}
@DS("datasource1")
/**修改角色对应权限设置*/
public rcpRes UpCrosinfo(List<RcpModel> clist){
 apper.DeleteRcp(clist.get(0).getRoleid());
 for(int i=0;i<clist.size();i++){
apper.InsertRcp(clist.get(i));
 }
return Getrcpinfo();
}
}
